<core-loading [hideUntil]="loaded">
    <div *ngIf="!summary">
        <ion-item class="ion-text-wrap addon-workshop-submission-title">
            <core-user-avatar [user]="profile" [courseId]="courseId" [userId]="profile?.id" slot="start" />
            <ion-label>
                <h2 *ngIf="submission.title">
                    <core-format-text [text]="submission.title" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"
                        [sanitize]="submission.offline" [wsNotFiltered]="true" />
                </h2>
                <p *ngIf="profile && profile?.fullname">{{profile.fullname}}</p>
                <p *ngIf="showGrade(submission.grade)" [class.addon-has-overriden-grade]="showGrade(submission.gradeover)">
                    {{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{submission.grade}}
                </p>
                <p *ngIf="showGrade(submission.gradeover)" class="addon-overriden-grade">
                    {{ 'addon.mod_workshop.gradeover' | translate }}: {{submission.gradeover}}
                </p>
                <p *ngIf="access.canviewallsubmissions && showGrade(submission.gradinggrade)">
                    {{ 'addon.mod_workshop.gradinggradeof' | translate:{$a: workshop.gradinggrade } }}: {{submission.gradinggrade}}
                </p>
            </ion-label>
            <ion-note slot="end" *ngIf="!submission.timemodified">
                <ion-icon name="fas-clock" aria-hidden="true" /> {{ 'core.notsent' | translate }}
            </ion-note>
            <ion-note slot="end" *ngIf="submission.timemodified">
                {{submission.timemodified | coreDateDayOrTime}}
                <div *ngIf="submission.offline">
                    <ion-icon name="fas-clock" aria-hidden="true" /> {{ 'core.notsent' | translate }}
                </div>
                <div *ngIf="submission.deleted">
                    <ion-icon name="fas-trash" aria-hidden="true" /> {{ 'core.deletedoffline' | translate }}
                </div>
            </ion-note>
        </ion-item>
        <ion-item class="ion-text-wrap" *ngIf="submission.content">
            <ion-label>
                <core-format-text [component]="component" [componentId]="componentId" [text]="submission.content" contextLevel="module"
                    [contextInstanceId]="module.id" [courseId]="courseId" [sanitize]="submission.offline" />
            </ion-label>
        </ion-item>
        <core-files [files]="submission.attachmentfiles" [component]="component" [componentId]="componentId" />
        <ion-item class="ion-text-wrap" *ngIf="viewDetails && submission.feedbackauthor">
            <core-user-avatar *ngIf="evaluateByProfile" [user]="evaluateByProfile" slot="start" [courseId]="courseId"
                [userId]="evaluateByProfile.id" />

            <ion-label>
                <p class="item-heading" *ngIf="evaluateByProfile && evaluateByProfile.fullname">
                    {{ 'addon.mod_workshop.feedbackby' | translate : {$a: evaluateByProfile.fullname} }}
                </p>
                <core-format-text [text]="submission.feedbackauthor" contextLevel="module" [contextInstanceId]="module.id"
                    [courseId]="courseId" />
            </ion-label>
        </ion-item>
        <ion-item *ngIf="viewDetails">
            <ion-label>
                <ion-button expand="block" (click)="gotoSubmission()">
                    {{ 'core.showmore' | translate }}
                    <ion-icon name="fas-chevron-right" slot="end" aria-hidden="true" />
                </ion-button>
            </ion-label>
        </ion-item>
    </div>

    <ion-item class="ion-text-wrap" *ngIf="summary" [detail]="submission.timemodified" (click)="gotoSubmission()"
        [button]="submission.timemodified">
        <core-user-avatar [user]="profile" slot="start" [courseId]="courseId" [userId]="profile?.id" />
        <ion-label>
            <h2 *ngIf="submission.title">
                <core-format-text [text]="submission.title" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"
                    [sanitize]="submission.offline" [wsNotFiltered]="true" />
            </h2>
            <p *ngIf="profile && profile.fullname">{{profile.fullname}}</p>
            <p *ngIf="submission.reviewedbydone">
                {{ 'addon.mod_workshop.receivedgrades' | translate }}: {{submission.reviewedbydone}} / {{submission.reviewedbycount}}
            </p>
            <p *ngIf="submission.reviewerofdone">
                {{ 'addon.mod_workshop.givengrades' | translate }}: {{submission.reviewerofdone}} / {{submission.reviewerofcount}}
            </p>
            <p *ngIf="!showGrade(submission.gradeover) && showGrade(submission.grade)">
                {{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{submission.grade}}
            </p>
            <p *ngIf="showGrade(submission.gradeover)" class="addon-overriden-grade">
                {{ 'addon.mod_workshop.submissiongradeof' | translate:{$a: workshop.grade } }}: {{submission.gradeover}}
            </p>
            <p *ngIf="access.canviewallsubmissions && showGrade(submission.gradinggrade)">
                {{ 'addon.mod_workshop.gradinggradeof' | translate:{$a: workshop.gradinggrade } }}: {{submission.gradinggrade}}
            </p>

            <ion-badge *ngIf="assessment && (showGrade(assessment.grade) || assessment.offline)" color="success" class="ion-text-wrap">
                {{ 'addon.mod_workshop.assessedsubmission' | translate }}
            </ion-badge>
            <ion-badge *ngIf="assessment && !showGrade(assessment.grade) && !assessment.offline" color="danger" class="ion-text-wrap">
                {{ 'addon.mod_workshop.notassessed' | translate }}
            </ion-badge>

        </ion-label>
        <ion-note slot="end" *ngIf="submission.timemodified">
            {{submission.timemodified | coreDateDayOrTime}}
            <div *ngIf="offline">
                <ion-icon name="fas-clock" aria-hidden="true" /> {{ 'core.notsent' | translate }}
            </div>
            <div *ngIf="submission.deleted">
                <ion-icon name="fas-trash" aria-hidden="true" /> {{ 'core.deletedoffline' | translate }}
            </div>
        </ion-note>
    </ion-item>
</core-loading>
